
function validateLogin(){
	var user=document.getElementsByName("userLogin")[0];
	var pass=document.getElementsByName("pwdLogin")[0];
	if((user.value=='')||(pass.value=='')){
		alert("Empty values in login form")
		return false;
	}
	return true;
}

function validateSearch(){
var tmp=document.getElementsByName("title")[0];
if(tmp.value==''){
	alert("Empty values in search form")
		return false;
	}
	return true;
}

function validateRegistration() {
				
if ( $ ( '#name' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the name!!' );
	return false; 
}
		
if ( $ ( '#surname' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the surname' );
	return false; 
}
				
if ( $ ( '#username' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the username!' );
	return false; 
}
				

if ( $ ( '#pass' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the password!' );
	return false; 
}
	
if ( $ ( '#pass_' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the password confirmation!' );
	return false; 
}
				
if ( $ ( '#pass' ).val()  != $ ( '#pass_' ).val() ) {
	alert ( 'Please note, the passwords do not match!' );
	return false; 
}
				
if ( $ ( '#mail' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the mail!' );
	return false; 
}
				
if ( $ ( '#mail_' ).val().length == 0 ) {
	alert ( 'Please note, you did not enter the mail confirmation!' );
	return false; 
}
				
if ( $ ( '#mail' ).val()  != $ ( '#mail_' ).val() ) {
	alert ( 'Please note, the emails do not match!' );
	return false; 
}

if( exist ( document.getElementById( 'username' ) ) || exist ( document.getElementById( 'mail' ) ) ){
	alert("username or email already registered");
	return false;
}
return true;
}

function exist ( obj ) {
	
	var resp = $.ajax ( {
		   type: "GET",
		   url: "exist.php",
		   data: obj.id+"="+ obj.value,
		   async: false,
		   success: function ( message ) {
						//alert ( obj.id + " esistente? " + message );
					}
			} ).responseText;
			if(resp=='YES')
				return true;
	return false;
}